﻿using UnityEngine;
using System.Collections;
using DICE_GS;

public class CharacterSummonResultManager : MonoBehaviour {
	public UISprite cardImage;
	public UILabel cardName;
	public UILabel unitName;
	public UILabel unitLevel;
	public UILabel unitHP;
	public UILabel unitAttack;
	public UILabel unitDefense;
	public UILabel unitMove;
	
	public static int summonedUnitId=0;
	// Use this for initialization
	void Start () {
		SetCardInfo();
		SetUnitInfo();
        LoadingWindow.window.ShowShortLoading();
		RestAPI.singleton.GetMyUnitList(RestReturnCallback);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void SetCardInfo()
	{
		CUnitData tmpUnitData = CUnitDataManager.Instance.GetUnitData(summonedUnitId);
		cardImage.spriteName = "card_"+tmpUnitData.name;
		cardName.text = tmpUnitData.devname;
	}
	
	void SetUnitInfo()
	{
		CUnitData tmpUnitData = CUnitDataManager.Instance.GetUnitData(summonedUnitId);
		unitName.text = tmpUnitData.devname;
		unitLevel.text = tmpUnitData.grade.ToString();
		unitHP.text = tmpUnitData.max_hp.ToString();
		unitAttack.text = tmpUnitData.attack_base.ToString();
		unitDefense.text = tmpUnitData.defense_base.ToString();
		unitMove.text = tmpUnitData.move_base.ToString();
	}

	void OnCLoseButtonClick()
	{
		Debug.LogError("CloseButton Clicked!");
		CSceneManager c = GameObject.FindObjectOfType(typeof(CSceneManager)) as CSceneManager;
		c.GoToWaitroomScene();
	}
	
	void RestReturnCallback(Hashtable returnData)
	{
        LoadingWindow.window.HideLoading();
	}
}

